﻿using System;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CaramelEngine.UnitTest
{
    [TestClass]
    public class DiceTests
    {
        [TestMethod]
        public void DiceCreate()
        {
            var item = new Dice.Dice();
            item.DiceSides.Should().Be(6);

            item = new Dice.Dice(4);
            item.DiceSides.Should().Be(4);
        }

        [TestMethod]
        public void DiceTestRoll()
        {
            var item = new Dice.Dice();

            for (int i = 0; i < 100; i++)
            {
                var roll = RollDice(item);
                roll.Should().BeGreaterThan(0).And.BeLessThan(7);
            }
        }

        private int RollDice(Dice.Dice dice)
        {
            return dice.Roll();
        }

        [TestMethod]
        public void DiceCollectionCreate()
        {
            var dc = new Dice.DiceCollection();
            dc.DiceTotal.Should().Be(0);
            dc.TypesOfDice.Should().BeEmpty();
        }

        [TestMethod]
        public void DiceCollectionCount()
        {
            var dc = new Dice.DiceCollection();
            dc.DiceRepository.Add(6, 3);
            dc.DiceTotal.Should().Be(3);

            dc.TypesOfDice.Count.Should().Be(1);

            dc.DiceRepository.Add(4, 2);

            dc.DiceTotal.Should().Be(5);
            dc.TypesOfDice.Count.Should().Be(2);
        }

    }
}
